home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / mail / thor201.lha / THOR_2.0 / thor.lha / scripts / AMBBS.NComm.script next >
Text File  |  1995-05-15  |  29KB  |  1,288 lines

  1. ; $VER: AMBBS.NComm.script 3.21 (07.05.95)
  2. ; ABBS/MBBS NComm Script for THOR
  3. ; By Eivind Nordseth, Ultima Thule Software
  4.  
  5.     REQUEST OFF
  6.  
  7.     set $dox = ""
  8.     set $oldconf = ""
  9.     set $gethold = "FALSE"
  10.     set $fixtimeout = ""
  11.     set $dtmpfile = ""
  12.     set $readmode = ""
  13.     set $private = ""
  14.     set $userinfo = "FALSE"
  15.     set $repfile = ""
  16.     set $qwkcommand = "Q QWK"
  17.     set $qwkcfg = "FALSE"
  18.     set $qwkerr = "TRUE"
  19.     set $rengrab = ""
  20.     set $doctrlx = "FALSE"
  21.     set $done = "FALSE"
  22.     set $notify = ""
  23.     set $packageOK = "FALSE"
  24.     set $gotprivfiles = "FALSE"
  25.     set $newfilesdate = ""
  26.  
  27.     when "AFront" gosub AFrontDetect
  28.     cli $THORPath"bin/ScriptServ \""$BBSName"\" WRITECFG EV 0 EV 1 EV 2 EV 3 EV 4 EV 5 EV 6 EV 7 EV 8 EV 10 EV 11 EV 12 EV 13 EV 14"
  29.  
  30.     if exists "t:privupl"$BBSName then cli "delete >nil: \"t:privupl"$BBSName"\""
  31.     if exists "t:filenote"$BBSName then cli "delete >nil: \"t:filenote"$BBSName"\""
  32.     if exists "t:NoLogOut" then cli "delete >nil: t:NoLogOut"
  33.     if exists "t:DoLogOut" then cli "delete >nil: t:DoLogOut"
  34.  
  35.     varfile "t:"$BBSName".CONFIG"
  36.  
  37.     readvar $CfgVer
  38.     readvar $BBSID
  39.     readvar $BBSType
  40.     readvar $Path
  41.     readvar $PostConf
  42.     readvar $UpLoadDir
  43.     readvar $UserName
  44.     readvar $UserStreet
  45.     readvar $UserAddress
  46.     readvar $UserCountry
  47.     readvar $UserPhone
  48.     readvar $NewFiles
  49.     readvar $AutoPDnl
  50.     readvar $AutoLogoff
  51.     readvar $UseColors
  52.     readvar $AnsiMenues
  53.     readvar $Bulletins
  54.     varfile close
  55.  
  56.     if !$CfgVer == "3" then message "Incompatible version of ScriptServ"
  57.     if !$CfgVer == "3" then goto AllDone
  58.  
  59.     cli "delete >nil: \"t:"$BBSName".CONFIG\""
  60.  
  61.     set $LogFile = $Path"ScriptMsg.txt"
  62.  
  63.     when "\r\nNO CARRIER\r\n" goto AllDone
  64.     send "^K\n\n"
  65.  
  66.     autoxfer off ; Turn off G&R commands
  67.     autoup off   ; Turn off Zmodem autoupload
  68.     autodown on  ; Turn on Zmodem autodownload
  69.  
  70.     if $BBSType == "MBBS"     then menuselect TRANSLATE 1 8 ; Use IBN character set
  71.     if $BBSType == "MBBS"     then set $charset = "IBN"     ; Use IBN character set
  72.     if $BBSType == "ABBS"     then menuselect TRANSLATE 1 0 ; Use ISO character set
  73.     if $BBSType == "ABBS"     then set $charset = "ISO"     ; Use ISO character set
  74.     if $BBSType == "MBBS_QWK" then menuselect TRANSLATE 1 8 ; Use IBN character set
  75.     if $BBSType == "MBBS_QWK" then set $charset = "IBN"     ; Use IBN character set
  76.     if $BBSType == "ABBS_QWK" then menuselect TRANSLATE 1 0 ; Use ISO character set
  77.     if $BBSType == "ABBS_QWK" then set $charset = "ISO"     ; Use IBN character set
  78.  
  79.     converse "FIRST name?" $UserName" Q\n"
  80.  
  81.     if $BBSType == "ABBS_QWK" then menuselect TRANSLATE 1 8 ; Use IBN character set
  82.     if $BBSType == "ABBS_QWK" then set $charset = "IBN"     ; Use IBN character set
  83.  
  84.     converse "will echo):" "\p\n"
  85.  
  86.     dwhen "AFront"
  87.  
  88.     capture "t:privupl"$BBSName
  89.  
  90.     when "--more--" send "C"
  91.     when "coming online" gosub SysOp
  92.     when "The following" set $gotprivfiles = "TRUE"
  93.  
  94.     if $BBSType == "MBBS"     then set $docmd = "CHAT N U L 0 MF 50 S IBN\n"
  95.     if $BBSType == "ABBS"     then set $docmd = "CHAT N U L 0 MF 50 S ISO\n"
  96.     if $BBSType == "MBBS_QWK" then set $docmd = "CHAT N U L 0 MF 50 S IBN\n"
  97.     if $BBSType == "ABBS_QWK" then set $docmd = "CHAT N U L 0 MF 50 S IBN\n"
  98.     gosub DoCommand
  99.  
  100. ;***************** Event loop
  101.     
  102.     wait "Command"
  103.     set $doctrlx = "TRUE"
  104.  
  105.     dwhen "The following"
  106.     capture off
  107.  
  108.     if !exists "t:"$BBSName".EVENTS" then goto afterEvents
  109.     varfile "t:"$BBSName".EVENTS"
  110.  
  111. eventLoop:
  112.     set $done = "FALSE"
  113.  
  114.     readvar $eventnr
  115.     readvar $event
  116.  
  117.     if $eventnr == "EOF" then goto evLoopEnd
  118.     if $event   == "EOF" then goto evLoopEnd
  119.  
  120.     if $event == "0"  then gosub EnterMsg
  121.     if $event == "1"  then gosub ReplyMsg
  122.     if $event == "2"  then gosub JoinConf
  123.     if $event == "3"  then gosub ResignConf
  124.     if $event == "4"  then gosub DownloadFile
  125.     if $event == "5"  then gosub UploadFile
  126.     if $event == "6"  then gosub GetConfList
  127.     if $event == "7"  then gosub ConfigureBBS
  128.     if $event == "8"  then gosub SendUserInfo
  129.     if $event == "10" then gosub GetNewFiles
  130.     if $event == "11" then gosub CommandEvent
  131.     if $event == "12" then gosub AutoLogOff
  132.     if $event == "13" then gosub RetractMsg
  133.     if $event == "14" then gosub RetractFile
  134.  
  135.     if $event == "7769"  then set $done = "TRUE"
  136.  
  137.     if  $done == "TRUE" then cli "run >nil: "$THORPath"bin/ScriptServ \""$BBSName"\" DONE "$eventnr
  138.     if !$done == "TRUE" then cli "run >nil: "$THORPath"bin/ScriptServ \""$BBSName"\" ERROR "$eventnr
  139.  
  140.     goto eventLoop    
  141.  
  142. evLoopEnd:
  143.     varfile close
  144.  
  145.     cli "delete >nil: \"t:"$BBSName".EVENTS\""
  146.  
  147. afterEvents:
  148.  
  149. ;***************** Grab messages
  150.  
  151.     set $rengrab = "y"
  152.  
  153.     if $BBSType == "ABBS_QWK" then goto HandleABBSQWK
  154.  
  155.     if $BBSType == "ABBS"     then set $docmd = "U GF MBBS\n"
  156.     if $BBSType == "ABBS"     then gosub DoCommand
  157.  
  158.     set $packageOK = "TRUE"
  159.  
  160.     set $docmd = "R DUMP ALL\n"
  161.     gosub DoCommand
  162.  
  163.     when "<0>" goto grabd
  164.  
  165.     converse "Command" "SE Z\n"
  166.  
  167. grabd:
  168.     dlwhen
  169.     goto AfterGrabing
  170.  
  171.  
  172. ;***************** Do ABBS_QWK packet handling
  173. HandleABBSQWK:
  174.     set $docmd = "U GF QWK\n"
  175.     gosub DoCommand
  176.  
  177.     if !exists $UpLoadDir$BBSID".REP" then goto NoABBSRepFile
  178.     
  179.     set $docmd = "Q MU\n"
  180.     gosub DoCommand
  181.  
  182.     when "parsed successfully" set $qwkerr = "FALSE"
  183.  
  184.     wait "B01"
  185.     upload $UpLoadDir$BBSID".REP",Z
  186.     gosub NoTimeout
  187.  
  188.     capture $Path"QWKMsg.txt"
  189.  
  190.     wait "Main Command"
  191.  
  192.     capture off
  193.     dlwhen
  194.     gosub SetUpTimeout
  195.  
  196.     if $qwkerr == "TRUE" then goto ABBSRepFileFail
  197.  
  198.     set $packageOK = "TRUE"
  199.  
  200.     cli "delete >nil: "$UpLoadDir$BBSID".REP"
  201.     cli "delete >nil: "$Path"QWKMsg.txt"
  202.     set $doctrlx = "TRUE"
  203.     goto NoABBSRepFile
  204.  
  205. ABBSRepFileFail:
  206.     set $appendsource = $Path"QWKMsg.txt"
  207.     set $appenddest = $LogFile
  208.     gosub AppendFile
  209.     set $doctrlx = "TRUE"
  210.  
  211. NoABBSRepFile:
  212.     set $docmd = "R DUMP ALL\n"
  213.     gosub DoCommand
  214.     gosub NoTimeout
  215.  
  216.     when "<0>" goto grabQwkDone
  217.  
  218.     converse "Command" "SE Z\n"
  219.  
  220. grabQwkDone:
  221.     dlwhen
  222.     goto AfterGrabing
  223.  
  224. ;***************** Package Done
  225. AfterGrabing:
  226.     set $doctrlx = "TRUE"
  227.     wait "Command"
  228.  
  229.     if $packageOK == "TRUE" then cli "run >nil: "$THORPath"bin/ScriptServ \""$BBSName"\" PACKAGEDONE"
  230.     set $rengrab = "y"
  231.  
  232. ;***************** Capture Newfiles.txt
  233.  
  234.     if !$NewFiles == "y" then goto AfterNewFiles
  235.  
  236.     set $docmd = ""
  237.     gosub DoCommand
  238.  
  239.     when "Detailed list (Enter=N):" send "n\n"
  240.  
  241.     cli "Delete >nil: "$Path"Newfiles.txt"
  242.     capture $Path"Newfiles.txt"
  243.  
  244.     if $newfilesdate == "" then set $newfilesdate = ";"
  245.     send "F N "$newfilesdate" ;\n"
  246.     gosub NoTimeout
  247.  
  248.     when "Read Command" goto NewFilesDone
  249.     wait "File Command"
  250.  
  251. NewFilesDone:
  252.     dwhen "Read Command"
  253.     dwhen "Detailed list (Enter=N):"
  254.     capture off
  255.     set $doctrlx = "TRUE"
  256.  
  257. AfterNewFiles:
  258. ;***************** Auto dnload private files
  259.  
  260.     if !$AutoPDnl == "y" then goto NoPrivUpl
  261.     if !$gotprivfiles == "TRUE" then goto NoPrivUpl
  262.     if !exists "t:privupl"$BBSName then goto NoPrivUpl
  263.  
  264.     cli $THORPath"bin/ScriptServ >\"t:privupl"$BBSName".tmp\" \""$BBSName"\" PrivUploadFile \"t:privupl"$BBSName"\""
  265.  
  266.     if !exists "t:privupl"$BBSName".tmp" then goto NoPrivUpl
  267.  
  268.     varfile "t:privupl"$BBSName".tmp"
  269.  
  270.     if !$doctrlx == "TRUE" then wait "Command"
  271.  
  272. PrivLoop:
  273.     readvar $dtmpfile    
  274.     if $dtmpfile == "" then goto PrivLoopEnd
  275.     if $dtmpfile == "EOF" then goto PrivLoopEnd
  276.     
  277.     send "F D "$dtmpfile"\n"
  278.     capture "t:filenote"$BBSName
  279.     gosub NoTimeout
  280.  
  281.     wait "Command"
  282.  
  283.     if !exists $LogFile then write $LogFile "Messages from script:\n"
  284.     write $LogFile "    Downloaded private file: "$dtmpfile"\n"
  285.  
  286.     capture off
  287.  
  288.     goto PrivLoop
  289.  
  290. PrivLoopEnd:
  291.     set $doctrlx = "TRUE"
  292.     varfile close
  293.     cli "delete >nil: \"t:privupl"$BBSName".tmp\""
  294.  
  295. NoPrivUpl:
  296.  
  297. ;***************** Get files in hold
  298.  
  299.     if exists "t:privupl"$BBSName then cli "delete >nil: \"t:privupl"$BBSName"\""
  300.     if !$gethold == "TRUE" then goto NoHold
  301.  
  302.     set $docmd = "F GET\n"
  303.     gosub DoCommand
  304.     gosub NoTimeout
  305.  
  306. NoHold:
  307. ;***************** Update filenotes of downloaded files.
  308.     if !exists "t:filenote"$BBSName then goto NoUpdateNotes
  309.  
  310.     if !$doctrlx == "TRUE" then wait "Command"
  311.     set $doctrlx = "TRUE"
  312.  
  313.     cli $THORPath"bin/ScriptServ \""$BBSName"\" UPDATEFILENOTES \"t:filenote"$BBSName"\""
  314.     cli "delete >nil: \"t:filenote"$BBSName"\""
  315.  
  316. NoUpdateNotes:
  317. ;***************** Ready for logout
  318.  
  319.     if exists "t:DoLogOut" then goto DoLogOut
  320.  
  321.     if $AutoLogoff == "n" then goto NoLogOut
  322.  
  323.     if exists "t:NoLogOut" then goto NoLogOut
  324.  
  325. DoLogOut:
  326.     set $docmd = "CHAT A U L 30 MF 0\n"
  327.     gosub DoCommand
  328.  
  329.     set $docmd = "G Y N Y\n"
  330.     gosub DoCommand
  331.  
  332.     when "\r\nNO CARRIER\r\n" goto Hanged
  333.     delay 2
  334.     repeat
  335.     hangup
  336.     delay 2
  337.     until !CARRIER
  338.  
  339. Hanged:
  340.     dlwhen
  341.     goto AllDone
  342.  
  343. NoLogOut:
  344.     set $docmd = "CHAT A U L 30 MF 0 W R\n"
  345.     gosub DoCommand
  346.  
  347.     dwhens
  348.     timeout 0
  349.  
  350. AllDone:
  351.     request on
  352.     end
  353.  
  354.  
  355. Hung:
  356.     beep
  357.     message "\nI think the board has hung."
  358.     message "\nTurn off this script within 20 seconds to stop me from logging out !!"
  359.     delay 20
  360.     beep
  361.     message "\nWARNING: Logout in progress.\n"
  362.     hangup
  363.     goto AllDone
  364.  
  365. SysOp:
  366.     send "Sorry, you are trying to chat with a script.\n"
  367.     send "Please put me back to the BBS at once.\n"
  368.     set $Timeouts = "0"
  369.     wait "SYSOP is going offline!"
  370.     set $Timeouts = "0"
  371.     return
  372.  
  373.  
  374. ;************************************************
  375. DoCommand:
  376.     if $doctrlx == "TRUE" then send "^X"
  377.     converse "Command" $docmd
  378.  
  379.     if !$rengrab == "" then gosub RenameGrab
  380.     if !$fixtimeout == "" then gosub SetupTimeout
  381.  
  382.     set $doctrlx = "FALSE"
  383.     return
  384.  
  385. ;************************************************
  386. NoTimeout:
  387.     set $fixtimeout = "d"
  388.     timeout 0
  389.     return
  390.  
  391. SetupTimeout:
  392.     set $fixtimeout = ""
  393.     set $Timeouts = "0"
  394.     timeout 60 gosub SendCTRLX
  395.     return
  396.  
  397. SendCTRLX:
  398.     set $fixtimeout = "d"
  399.     if $Timeouts == "2" then timeout 20 gosub Hung
  400.     if $Timeouts == "2" then send "^X"
  401.  
  402.     if $Timeouts == "1" then send $docmd
  403.     if $Timeouts == "1" then set $Timeouts = "2"
  404.  
  405.     if $Timeouts == "0" then send "^X"
  406.     if $Timeouts == "0" then set $Timeouts = "1"
  407.     return
  408.  
  409. Hung:
  410.     beep
  411.     message "\nI think the board has hung."
  412.     message "\nTurn off this script within 20 seconds to stop me from logging out !!"
  413.     delay 20
  414.     beep
  415.     message "\nWARNING: Logout in progress.\n"
  416.     hangup
  417.     goto AllDone
  418.  
  419. ;************************************************
  420. RenameGrab:
  421.     set $rengrab = ""
  422.     cli $THORPath"bin/ScriptServ \""$BBSName"\" RENAMEGRAB"
  423.     cli "run >nil: sys:rexxc/rx 'address THOR.01 RESCAN'"
  424.     return
  425.  
  426. ;************************************************
  427. ; Enter message subroutine
  428. ; Uses variables:
  429. ;    $conf     - conference for message
  430. ;    $sendto     - user message is to (Empty string is equal to ALL)
  431. ;    $subject    - subject of message
  432. ;    $msgfile    - file message is in
  433. ;    $private    - private message (0/!0)
  434. EnterMsg:
  435.  
  436.     readvar    $conf
  437.     readvar    $sendto
  438.     readvar    $msgfile
  439.     readvar    $subject
  440.     readvar    $private
  441.     if $private == "" then set $private = "0"
  442.     if !$private == "0" then set $private = "y"
  443.     if $private == "0" then set $private = "n"
  444.  
  445.     set $done = "TRUE"
  446.  
  447.     when "Private message" send $private"\n"
  448.     when "other users (Enter=N)" send "\n"
  449.     when "Send message to" send $sendto"\n"
  450.  
  451.     when "enter both the first AND" goto etomyself
  452.     when "that name is not registered" goto etomyself
  453.     when "ALL is not allowed here!" goto etomyself
  454.  
  455.     when "READ ONLY conference. Us" goto einpost1
  456.     when "not a member of this con" goto einpost2
  457.     when "Invalid conference selec" goto einpost3
  458.     when "Topics are:"              goto einpost4
  459.     when "Couldn't save msg!"       goto einpost5
  460.  
  461.     if $conf == $oldconf then goto InConf
  462.  
  463.     set $docmd = "J "$conf"\n"
  464.     gosub DoCommand
  465.     if $done == "FALSE" then goto enterRet
  466.  
  467.     set $oldconf = $conf
  468.  
  469. InConf:
  470.     if $sendto == "" then set $sendto = "ALL"
  471.  
  472.     set $docmd = "E\n"
  473.     gosub DoCommand
  474.     if $done == "FALSE" then goto enterRet
  475.  
  476.     set $dlewhen = "FALSE"
  477.     set $dox = ""
  478.  
  479.     gosub SendMessage
  480.     if $done == "FALSE" then goto enterRet
  481.  
  482. enterErr:
  483.     wait "Command"
  484.  
  485.     dlwhen
  486.     dlwhen
  487.     dlwhen
  488.     dlwhen
  489.     dlwhen
  490.     dlwhen
  491.     dlwhen
  492.     dlwhen
  493.     dlwhen
  494.     dlwhen
  495.     dlwhen
  496.  
  497.     set $doctrlx = "TRUE"
  498.  
  499. enterRet:
  500.     return
  501.  
  502. etomyself:
  503.     gosub Startlogfile
  504.     write $LogFile "    Conference "$conf", unable to enter message to "$sendto"\n"
  505.     send "^X\n"
  506.     set $done = "FALSE"
  507.  
  508.     goto enterErr
  509.  
  510. einpost5:
  511.     gosub Startlogfile
  512.     write $LogFile "    The BBS couldn't save the message.\n"
  513.     set $done = "FALSE"
  514.  
  515.     goto enterErr
  516.  
  517. einpost4:
  518.     gosub Startlogfile
  519.     write $LogFile "    Invalid conference topic: "$conf"\n"
  520.     send "\n"
  521.     set $oldconf = ""
  522.     set $done = "FALSE"
  523.  
  524.     goto enterErr
  525.  
  526. einpost3:
  527.     gosub Startlogfile
  528.     write $LogFile "    Invalid conference selection: "$conf"\n"
  529.     set $oldconf = ""
  530.     gosub FixJoinErr
  531.     set $done = "FALSE"
  532.  
  533.     goto enterErr
  534.  
  535. einpost2:
  536.     gosub Startlogfile
  537.     write $LogFile "    User "$sendto" in not a member of conference "$conf"\n"
  538.     set $done = "FALSE"
  539.  
  540.     goto enterErr
  541.  
  542. einpost1:
  543.     gosub Startlogfile
  544.     write $LogFile "    Conference "$conf" is READ ONLY\n"
  545.     set $done = "FALSE"
  546.  
  547.     goto enterErr
  548.  
  549.  
  550. ;************************************************
  551. ; Reply message subroutine
  552. ; Uses variables:
  553. ;    $conf         - conference for message
  554. ;    $replyto     - reply to message
  555. ;    $subject    - subject of message
  556. ;    $msgfile    - file message is in
  557. ;    $private    - private message (y/n)
  558. ;    $sendto        - user the message is to
  559. ReplyMsg:
  560.     readvar $conf
  561.     readvar $sendto
  562.     readvar $msgfile
  563.     readvar $dummy
  564.     readvar $subject
  565.     readvar $replyto
  566.     readvar $private
  567.     
  568.     if $private == "" then set $private = "0"
  569.     if !$private == "0" then set $private = "y"
  570.     if $private == "0" then set $private = "n"
  571.  
  572.     set $done = "TRUE"
  573.  
  574.     when "Private message"          send $private"\n"
  575.     when "Include original message" send "n\n"
  576.     when "READ ONLY conference you" goto readonlyconf
  577.     when "Invalid conference selec" goto invalidconf
  578.     when "Topics are:"              goto invalidtopic
  579.     when "not available for reply." goto notavail
  580.     when "Message not found !"      goto REnotfound
  581.     when "not a member of this con" goto nomember
  582.     when "Couldn't save msg!"       goto ReSaveErr
  583.  
  584.     if $conf == $oldconf then goto InConf2
  585.  
  586.     set $docmd = "J "$conf"\n"
  587.     gosub DoCommand
  588.     if $done == "FALSE" then goto replyRet
  589.  
  590.     set $oldconf = $conf
  591. InConf2:
  592.     set $docmd = "R RE "$replyto"\n"
  593.     gosub DoCommand
  594.     if $done == "FALSE" then goto replyRet
  595.  
  596.     set $dox = "^X"
  597.     gosub SendMessage
  598.     if $done == "FALSE" then goto replyRet
  599.  
  600. replyErr:
  601.     dlwhen
  602.     dlwhen
  603.     dlwhen
  604.     dlwhen
  605.     dlwhen
  606.     dlwhen
  607.     dlwhen
  608.     dlwhen
  609.  
  610.     wait "Command"
  611.     set $doctrlx = "TRUE"
  612.  
  613. replyRet:
  614.     return
  615.  
  616. readonlyconf:
  617.     gosub Startlogfile
  618.     write $LogFile "    Conference "$conf" is READ ONLY, unable to reply message "$replyto"\n"
  619.     set $done = "FALSE"
  620.  
  621.     goto replyErr
  622.  
  623. invalidconf:
  624.     gosub Startlogfile
  625.     write $LogFile "    Invalid conference selection: "$conf", unable to reply message "$replyto"\n"
  626.     gosub FixJoinErr
  627.     set $done = "FALSE"
  628.  
  629.     goto replyErr
  630.  
  631. invalidconf:
  632.     gosub Startlogfile
  633.     write $LogFile "    Invalid conference topic: "$conf", unable to reply message "$replyto"\n"
  634.     send "\n"
  635.     set $done = "FALSE"
  636.  
  637.     goto replyErr
  638.  
  639. nomember:
  640.     gosub Startlogfile
  641.     write $LogFile "    "$sendto" is not member of conference: "$conf", unable to reply message "$replyto"\n"
  642.     set $done = "FALSE"
  643.  
  644.     goto replyErr
  645.  
  646. notavail:
  647.     gosub Startlogfile
  648.     write $LogFile "    Message "$replyto" in "$conf" not available for reply\n"
  649.     set $done = "FALSE"
  650.  
  651.     goto replyErr
  652.  
  653. REnotfound:
  654.     gosub Startlogfile
  655.     write $LogFile "    Message "$replyto" in "$conf" was not found, and was not available for reply\n"
  656.     set $done = "FALSE"
  657.  
  658.     goto replyErr
  659.  
  660. ReSaveErr:
  661.     gosub Startlogfile
  662.     write $LogFile "    The BBS couldn't save the message.\n"
  663.     set $done = "FALSE"
  664.  
  665.     goto replyErr
  666.  
  667.  
  668. ;************************************************
  669. ; Subroutine for sending message
  670. SendMessage:
  671.     when "--7-" goto sendit
  672.     converse "Subject" $dox$subject"\n"
  673.     wait "--7-"
  674. sendit:
  675.     dlwhen
  676.     if $userinfo == "FALSE" then goto nouserinfo
  677.  
  678.     if $BBSType == "ABBS"     then gosub SendABBSClear
  679.     if $BBSType == "ABBS_QWK" then gosub SendABBSClear
  680.  
  681.     if $BBSType == "MBBS"     then send "^KC" 
  682.     if $BBSType == "MBBS_QWK" then send "^KC" 
  683.     
  684. nouserinfo:
  685.     send "^KZ"
  686.     ascsend $Path$msgfile
  687.  
  688.     send "\w^Z^Z"
  689.     return
  690.  
  691. ;************************************************
  692. ; ABBS clear editor
  693. SendABBSClear:
  694.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  695.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  696.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  697.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  698.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  699.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  700.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  701.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  702.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  703.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  704.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  705.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  706.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  707.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  708.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  709.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  710.     return
  711.  
  712.  
  713. ;************************************************
  714. Startlogfile:
  715.     if !exists $LogFile then write $LogFile "Messages from script:\n"
  716.     write $LogFile "Error in event nr "$eventnr":\n"
  717.     return
  718.  
  719. ;************************************************
  720. FixJoinErr:
  721.     if $BBSType == "MBBS" then converse "name to join" "\n"
  722.     if $BBSType == "MBBS_QWK" then converse "name to join" "\n"
  723.  
  724.     if $BBSType == "ABBS" then send "^K"
  725.     if $BBSType == "ABBS" then converse "Join conference:" "\n"
  726.  
  727.     if $BBSType == "ABBS_QWK" then send "^K"
  728.     if $BBSType == "ABBS_QWK" then converse "Join conference:" "\n"
  729.  
  730.     return
  731.  
  732. ;************************************************
  733. ; Join conference
  734. ; Uses variables:
  735. ;    $conf - conference to join
  736. JoinConf:
  737.     readvar $conf
  738.  
  739.     set $done = "TRUE"
  740.     when "Invalid conference sele" gosub joinerr
  741.     when "Topics are:" gosub topicserr
  742.  
  743.     set $docmd = "J "$conf"\n"
  744.     gosub DoCommand
  745.     set $oldconf = $conf
  746.  
  747.     wait "Command"
  748.     dlwhen 
  749.     dlwhen
  750.     set $doctrlx = "TRUE"
  751.     
  752.     return
  753.  
  754. joinerr:
  755.     gosub Startlogfile
  756.     write $LogFile "    Invalid conference selection: "$conf", Unable to join\n"
  757.     gosub FixJoinErr
  758.     set $oldconf = ""
  759.     set $done = "FALSE"
  760.     return
  761.  
  762. topicserr:
  763.     gosub Startlogfile
  764.     write $LogFile "    Invalid conference topic: "$conf", Unable to join\n"
  765.     send "\n"
  766.     set $oldconf = ""
  767.     set $done = "FALSE"
  768.     return
  769.     
  770. ;************************************************
  771. ; Resign conference
  772. ; Uses variables:
  773. ;    $conf - conference to resign
  774. ResignConf:
  775.     readvar $conf
  776.  
  777.     when "Invalid conference sele" goto resconferr
  778.     when "Topics are:" goto restopicerr
  779.  
  780.     set $done = "TRUE"
  781.     set $oldconf = ""
  782.  
  783.     set $docmd = "J "$conf"\n"
  784.     gosub DoCommand
  785.     if $done == "FALSE" then goto resignRet
  786.  
  787.     set $docmd = "RES Y\n"
  788.     gosub DoCommand
  789.     if $done == "FALSE" then goto resignRet
  790.  
  791. resignErr:
  792.     dlwhen
  793.     dlwhen
  794.  
  795.     wait "Command"
  796.     set $doctrlx = "TRUE"
  797.  
  798. resignRet:
  799.     return
  800.  
  801. resconferr:
  802.     gosub Startlogfile
  803.     write $LogFile "    Invalid conference selection: "$conf", unable to resign\n"
  804.     gosub FixJoinErr
  805.     set $done = "FALSE"
  806.     goto resignErr
  807.  
  808. restopicerr:
  809.     gosub Startlogfile
  810.     write $LogFile "    Invalid conference topic: "$conf", unable to resign\n"
  811.     send "\n"
  812.     set $done = "FALSE"
  813.     goto resignErr
  814.  
  815. ;************************************************
  816. ; Append a file to the en of the other.
  817. ; Uses variables:
  818. ;  $appendsource - File to append.
  819. ;  $appenddest   - Destination.
  820. AppendFile:
  821.     if !exists $appenddest then goto afNotExists
  822.  
  823.     cli "join >nil: \""$appenddest"\" \""$appendsource"\" TO \""$appenddest".tmp\""
  824.     cli "delete >nil: \""$appenddest"\""
  825.     cli "rename >nil: \""$appenddest".tmp\" \""$appenddest"\""
  826.     cli "delete >nil: \""$appendsource"\""
  827.     return    
  828.  
  829. afNotExists:
  830.     cli "rename >nil: \""$appendsource"\" \""$appenddest"\""
  831.     return
  832.  
  833.  
  834. ;************************************************
  835. GetConfList:
  836.     set $docmd = ""
  837.     gosub DoCommand
  838.  
  839.     set $done = "TRUE"
  840.     cli "Delete >nil: "$Path"Conferences.txt"
  841.     capture $Path"Conferences.txt"
  842.  
  843.     send "R SH A\n"
  844.  
  845.     wait "Command"
  846.     set $doctrlx = "TRUE"
  847.  
  848.     capture off
  849.  
  850.     return
  851.  
  852. ;************************************************
  853. ; Download file subroutine
  854. ; Uses variables:
  855. ;    $filename - name of file to download
  856. DownloadFile:
  857.  
  858.     readvar $filename
  859.  
  860.     set $done = "TRUE"
  861.  
  862.     set $fnotfound  = "FALSE"
  863.     set $fnotaccess = "FALSE"
  864.     set $DNnotavail = "FALSE"
  865.     set $fexpired   = "FALSE"
  866.  
  867.     when "File not found!"           set $fnotfound = "TRUE"
  868.     when "You are not allowed"       set $fnotaccess = "TRUE"
  869.     when "not available, please"     set $DNnotavail = "TRUE"
  870.     when "has expired."              set $fexpired = "TRUE"
  871.     when "ate files may not be move" set $dfnotmove = "TRUE"
  872.     set $gethold = "TRUE"
  873.     set $dfnotmove = "FALSE"
  874.  
  875.     set $dtmpfile = $filename
  876.  
  877.     set $docmd = "F ADD "$filename"\n"
  878.     gosub DoCommand
  879.     capture "t:filenote"$BBSName
  880.  
  881.     wait "Command"
  882.     capture off
  883.     if $fnotfound  == "TRUE" then gosub fnotfound
  884.     if $fnotaccess == "TRUE" then gosub fnotaccess
  885.     if $DNnotavail == "TRUE" then gosub DNnotavail
  886.     if $fexpired   == "TRUE" then gosub fexpired
  887.     if $dfnotmove  == "TRUE" then gosub dferr
  888.     gosub FixDnlWhens
  889.     set $doctrlx = "TRUE"
  890.     return
  891.  
  892. dferr:
  893.     send "F D "$dtmpfile"\n"
  894.     capture "t:filenote"$BBSName
  895.     gosub NoTimeout
  896.  
  897.     wait "Command"
  898.     capture off
  899.     return
  900.  
  901.  
  902. fnotaccess:
  903.     gosub Startlogfile
  904.     write $LogFile "Error: Unable to download file \""$dtmpfile"\", you don't have download access\n"
  905.     set $done = "FALSE"
  906.     return
  907.  
  908. fnotfound:
  909.     gosub Startlogfile
  910.     write $LogFile "Error: Unable to download file \""$dtmpfile"\", file not found\n"
  911.     set $done = "FALSE"
  912.     return
  913.  
  914. DNnotavail:
  915.     gosub Startlogfile
  916.     write $LogFile "Error: Unable to download file \""$dtmpfile"\", file not available.\n       Please check with sysop.\n"
  917.     set $done = "FALSE"
  918.     return
  919.  
  920. fexpired:
  921.     gosub Startlogfile
  922.     write $LogFile "Error: Unable to download file \""$dtmpfile"\", your file time expired\n"
  923.     return
  924.  
  925. FixDnlWhens:
  926.     dwhen "File not found!"
  927.     dwhen "You are not allowed"
  928.     dwhen "not available, please" 
  929.     dwhen "ate files may not be move"
  930.     dwhen "has expired."
  931.     return
  932.  
  933. ;************************************************
  934. ; Upload file subroutine
  935. ; Uses variables:
  936. ;    $filename    - name of file to upload
  937. ;    $filedescr    - short description of file
  938. ;    $notify        - download notification (y/n)
  939. ;    $detailed    - detailed description for file
  940. ;    $sendto        - private upload to user (empty string/"ALL" = public file)
  941. ;    $localfile    - path/filename to upload.
  942. ;    $conf            - Try to make file private to conf (if $conf != "")
  943.  
  944. UploadFile:
  945.  
  946.     readvar $filename
  947.     readvar $filedescr
  948.     readvar $sendto
  949.     readvar $conf
  950.     if !$BBSType == "MBBS" then goto Upl1
  951.     readvar $notify
  952.  
  953.     if $notify == "" then set $notify = "0"
  954.     if !$notify == "0" then set $notify = "y"
  955.     if $notify == "0" then set $notify = "n"
  956.     
  957. Upl1:
  958.     readvar $detailed
  959.     readvar $localfile
  960.  
  961.     set $msgfile = ""
  962.     set $done = "TRUE"
  963.  
  964.     if $localfile == "" then set $localfile = $UpLoadDir$filename
  965.     if !exists $localfile then goto nofileupload
  966.  
  967.     if $conf == "" then goto AfterUplJoin
  968.  
  969.     when "Invalid conference sele" gosub joinerr
  970.     when "Topics are:" gosub topicserr
  971.  
  972.     set $docmd = "J "$conf"\n"
  973.     gosub DoCommand
  974.     set $oldconf = $conf
  975.  
  976.     wait "Command"
  977.                                                                                                                       dlwhen 
  978.     dlwhen           
  979.     set $doctrlx = "TRUE"
  980.     
  981.     if $done == "FALSE" then goto uplRet
  982.     
  983.  
  984. AfterUplJoin:
  985.  
  986.     when "enter both the first AND" goto puperr
  987.     when "that name is not registered" goto puperr
  988.     when "ALL is not allowed here!" goto puperr
  989.  
  990.     when "Invalid file name!" goto upinvfile
  991.     when "File exists already" goto fexists
  992.     when "You are not allowed" goto UPnotallowed
  993.     when "each download" send $notify"\n"
  994.  
  995.     when "file to be publicly ava" send "\n"
  996.     when "Directory name, <?>=lis" send "\n"
  997.  
  998.     if  $conf == "" then when "rivate to confer" send "n\n"
  999.     if !$conf == "" then when "rivate to confer" send "y\n"
  1000.  
  1001.     if !$sendto == "" then set $docmd = "F PUP "$sendto"\n"
  1002.     if $sendto == "ALL" then set $docmd = "F UP\n"
  1003.     if $sendto == "" then set $docmd = "F UP\n"
  1004.  
  1005.     gosub DoCommand
  1006.     if $done == "FALSE" then goto uplRet
  1007.  
  1008.     converse "ile name" $filename"\n"
  1009.     converse "ion of file" $filedescr"\n"
  1010.  
  1011.     wait "B01"
  1012.  
  1013.     upload $localfile,Z
  1014.     gosub NoTimeout
  1015.  
  1016.     when "Command" goto uplfail
  1017.  
  1018.     if $detailed == "" then goto NoDetailed
  1019.  
  1020.     converse "description (Enter=Y)" "Y\n"
  1021.     gosub SetupTimeout
  1022.     set $msgfile = $detailed
  1023.     gosub SendMessage
  1024.     if $done == "FALSE" then goto uplRet
  1025.     goto uplLateErr
  1026.  
  1027. NoDetailed:
  1028.     converse "description (Enter=Y)" "N\n"
  1029.  
  1030. uplLateErr:
  1031.     dlwhen
  1032. uplErr:
  1033.     dlwhen    
  1034.     dlwhen
  1035.     dlwhen
  1036.     dlwhen
  1037.     dlwhen
  1038.     dlwhen
  1039.     dlwhen
  1040.     dlwhen
  1041.     dlwhen
  1042.  
  1043.     wait "Command"
  1044.     set $doctrlx = "TRUE"
  1045. uplRet:
  1046.     return
  1047.  
  1048. puperr:
  1049.     gosub Startlogfile
  1050.     write $LogFile "Error: Unable to do a private upload of "$filename"\n"
  1051.     write $LogFile "       User "$sendto" is not registered\n"
  1052.     send "^X\n"
  1053.     set $done = "FALSE"
  1054.     goto uplErr
  1055.  
  1056. upinvfile:
  1057.     gosub Startlogfile
  1058.     write $LogFile "Error: Unable to upload "$filename", filename is invalid\n"
  1059.     send "^X\n"
  1060.     set $done = "FALSE"
  1061.     goto uplErr
  1062.  
  1063. fexists:
  1064.     gosub Startlogfile
  1065.     write $LogFile "Error: Unable to upload "$filename", file already exists\n"
  1066.     send "^X\n"
  1067.     set $done = "FALSE"
  1068.     goto uplErr
  1069.  
  1070. UPnotallowed:
  1071.     gosub Startlogfile
  1072.     write $LogFile "Error: Unable to upload "$filename", you don't have download access\n"
  1073.     set $done = "FALSE"
  1074.     goto uplErr
  1075.  
  1076. uplfail:
  1077.     gosub Startlogfile
  1078.     write $LogFile "Error: Unable to upload "$filename", upload failed\n"
  1079.     set $done = "FALSE"
  1080.     set $doctrlx = "TRUE"
  1081.     goto uplLateErr
  1082.  
  1083. nofileupload:
  1084.     gosub Startlogfile
  1085.     write $LogFile "Error: Unable to upload "$filename", file not found\n"
  1086.     set $done = "FALSE"
  1087.     goto uplRet
  1088.  
  1089. ;************************************************
  1090. ; Do a custom command
  1091. ; Uses variables:
  1092. ;  $commandstring - Command to execute.
  1093. CommandEvent:
  1094.     readvar $commandstring
  1095.  
  1096.     write $LogFile "Executing custom command:\n"
  1097.  
  1098.     set $docmd = $commandstring"\n"
  1099.     gosub DoCommand
  1100.  
  1101.     capture $LogFile
  1102.  
  1103.     gosub NoTimeout
  1104.  
  1105.     when "File Command"      goto CmdEvDone
  1106.     when "Main Command"      goto CmdEvDone
  1107.     when "Utility Command"   goto CmdEvDone
  1108.     when "SYSOP Command"     goto CmdEvDone
  1109.     when "SIGOP Command"     goto CmdEvDone
  1110.     when "Misc Command"      goto CmdEvDone
  1111.     when "Mark Command"      goto CmdEvDone
  1112.     when "Read Ref Command"  goto CmdEvDone
  1113.     
  1114.     wait "Read Command"
  1115.  
  1116. CmdEvDone:
  1117.     dlwhen
  1118.     dlwhen
  1119.     dlwhen
  1120.     dlwhen
  1121.     dlwhen
  1122.     dlwhen
  1123.     dlwhen
  1124.     dlwhen
  1125.  
  1126.     capture off
  1127.     write $LogFile "\n"
  1128.     set $done = "TRUE"
  1129.     set $doctrlx = "TRUE"
  1130.     set $oldconf = ""
  1131.     return
  1132.  
  1133. ;************************************************
  1134. ; Send user info
  1135. ; Uses variables:
  1136. ;    $msgfile    - file user info is in
  1137. SendUserInfo:
  1138.     readvar $msgfile
  1139.  
  1140.     when "no resumé user info on this" goto NoUserInfo
  1141.  
  1142.     set $docmd = "Q EDIT\n"
  1143.     gosub DoCommand
  1144.  
  1145.     converse "number displayed (Enter=" "y\n"
  1146.  
  1147.     set $userinfo = "TRUE"
  1148.  
  1149.     gosub SendMessage
  1150.  
  1151.     set $userinfo = "FALSE"
  1152.     set $done = "TRUE"
  1153.  
  1154. uinErr:
  1155.     wait "Command"
  1156.     set $doctrlx = "TRUE"
  1157.  
  1158.     dlwhen
  1159.  
  1160.     return
  1161.  
  1162. NoUserInfo:
  1163.     gosub Startlogfile
  1164.     write $LogFile "Error: Sorry, no resumé user info on this system!"
  1165.     goto uinErr    
  1166.  
  1167.  
  1168. ;************************************************
  1169. ; Set up BBS configuration
  1170. ConfigureBBS:
  1171.     if $BBSType == "MBBS" then goto SetMBBSMode
  1172.     if $BBSType == "MBBS_QWK" then goto SetMBBSMode
  1173.  
  1174.     set $docmd = "R\n"
  1175.     gosub DoCommand
  1176.     when "Read Ref Co" set $readmode = "1"
  1177.     when "Read Co" set $readmode = "2"
  1178.     wait "Command"
  1179.     dlwhen
  1180.     dlwhen
  1181.     set $doctrlx = "TRUE"
  1182.     if $readmode == "2" then goto AfterSetMode
  1183.     set $docmd = "MODE\n"
  1184.     gosub DoCommand
  1185.     goto AfterSetMode
  1186.  
  1187. SetMBBSMode:
  1188.     set $qwkcfg = "TRUE"
  1189.  
  1190.     set $docmd = "R MODE M\n"
  1191.     gosub DoCommand
  1192.  
  1193. AfterSetMode:
  1194.     set $docmd = "u m y "$AnsiMenues" "$UseColors" y n y\n"
  1195.     gosub DoCommand
  1196.  
  1197.     if $BBSType == "ABBS" then gosub SetSpNN
  1198.     if $BBSType == "ABBS_QWK" then gosub SetSpNN
  1199.  
  1200.     if $BBSType == "ABBS_QWK" then set $docmd = "gf b "$Bulletins"\n"
  1201.     if $BBSType == "ABBS_QWK" then gosub DoCommand
  1202.  
  1203.     set $docmd = "u addr\n"
  1204.     gosub DoCommand
  1205.  
  1206.     converse "treet address" "^X"$UserStreet"\n"
  1207.     converse "code and town" "^X"$UserAddress"\n"
  1208.  
  1209.     if $UserPhone == "" then set $UserPhone = "-"
  1210.     converse "ome telephone number" "^X"$UserPhone"\n"
  1211.  
  1212.     converse "ork telephone number" "\n"
  1213.  
  1214.     wait "Command"
  1215.     set $doctrlx = "TRUE"
  1216.     set $done = "TRUE"
  1217.     return
  1218.  
  1219. SetSpNN:
  1220.     set $docmd = "sp n n\n"
  1221.     gosub DoCommand
  1222.     return
  1223.  
  1224. ;************************************************
  1225. ; Set get new files flag.
  1226. ; Uses variables:
  1227. ;    $newfilesdate    - date to use for newfiles.
  1228.  
  1229. GetNewFiles:
  1230.  
  1231.     readvar $newfilesdate
  1232.  
  1233.     set $NewFiles = "y"
  1234.     set $done = "TRUE"
  1235.  
  1236.     return
  1237.  
  1238.  
  1239. ;************************************************
  1240. ; Set the autologoff flag.
  1241. ; Uses variables:
  1242. ;  $boolean - Logoff (y/n)
  1243. AutoLogOff:
  1244.     readvar $boolean
  1245.  
  1246.     set $AutoLogoff = "y"
  1247.     if $boolean == "0" then set $AutoLogoff = "n"
  1248.     set $done = "TRUE"
  1249.  
  1250.     return
  1251.  
  1252. ;************************************************
  1253. ; Retract a message.
  1254. ; Uses variables:
  1255. ;  $conf     - Conference the message is in.
  1256. ;  $reforgnr - Number of message to kill.
  1257. RetractMsg:
  1258.     readvar $conf
  1259.     readvar $reforgnr
  1260.  
  1261.     set $docmd = "j "$conf" "$reforgnr" kill\n"
  1262.     gosub DoCommand
  1263.  
  1264.     wait "Command"
  1265.     set $doctrlx = "TRUE"
  1266.     set $done = "TRUE"
  1267.     return
  1268.  
  1269. ;************************************************
  1270. ; Retract a file
  1271. ; Uses variables:
  1272. ;  $filename - File name to kill
  1273. RetractFile:
  1274.     readvar $filename
  1275.  
  1276.     set $docmd = "f ret "$filename " y\n"
  1277.     gosub DoCommand
  1278.  
  1279.     wait "Command"
  1280.     set $doctrlx = "TRUE"
  1281.     set $done = "TRUE"
  1282.     return
  1283.  
  1284. AFrontDetect:
  1285.     send "\e\e"
  1286.     message "\nA nice front door escaped!\n"
  1287.     return
  1288.